import request from "./request.js"

// 获取所有用户
export function getUsers(){
	return request({
		url: '/users',
		method: 'GET'
	})
}

//判断学号是否已经存在
export function isExistSno(sno){
	return request({
		url: '/sno',
		method: 'POST',
		data: {
			sno: sno
		}
	})
}

// 分页查询用户
export function getUsersByPage(currentPage, pageSize, searchConditions){
	return request({
		url: '/user/page',
		method: 'POST',
		params:{
			currentPage,
			pageSize
		},
		data: {
			conditions: searchConditions
		}
	})
}

// 通过用户名获取当前用户信息
export function getCurrentUserByUsername(username){
	return request({
		url: '/user/currentUser',
		method: 'GET',
		params: { username }
	})
}

// 批量删除用户
export function delBatchUsers(ids){
	return request({
		url: '/user/batch',
		method: 'DELETE',
		data: {
			ids: ids
		}
	})
}

//根据用户id删除用户
export function delUserById(id){
	return request({
		url: `/user?id=${id}`,
		method: 'DELETE'
	})
}

// 更新用户信息
export function updateUser(form){
	return request({
		url: '/user',
		method: 'PUT',
		data:{ ...form }
	})
}

// 修改密码
export function changePassword(password){
	return request({
		url:'/user/password',
		method: 'PUT',
		params:{ password }
	})
}

// 重置密码
export function resetPassword(uid){
	return request({
		url: '/user/resetPwd',
		method: 'PUT',
		params: { uid }
	})
}

//查询出所有角色为辅导员的用户
export function getAllInstructor(){
	return request({
		url: '/user/instructor',
		method: 'GET'
	})
}

//根据用户名查询所属辅导员
export function getInstructorByStudentId(studentId){
	return request({
		url: '/user/instructor/'+studentId,
		method: 'GET',
	})
}

//学生与辅导员建立关系
export function addInstructorIdAndStudentId(instructorId,studentId){
	return request({
		url: '/user/instructor/student',
		method: 'POST',
		data:{
			instructorId:instructorId,
			studentId:studentId
		}
	})
}

// 获取所有班级
export function getAllClass(){
	return request({
		url: '/grade',
		method: 'GET'
	})
}


//所有今日未打卡的学生信息
export function getAllNoClockStudent(){
	return request({
		url: '/user/noClock',
		method: 'GET'
	})
}

// 今日已打卡学生位置情况
export function getPositionToday(position){
	return request({
		url: '/today/position/' + position,
		method: 'GET'
	})
}

// 今日学生健康情况
export function getHealthStudentToday(){
	return request({
		url: '/today/health/count',
		method: 'GET'
	})
}

// 今日所有身体不健康的学生
export function getAllNoHealthStudentToday(){
	return request({
		url: '/today/health/exception',
		method: 'GET'
	})
}